SlideShare a Scribd company logo
Omniauth Gem




All, Every and                  Authentication
 Everywhere




                 Omni + auth        By
                                    Sumit Munot
How to Use Omniauth to Authenticate Our
                Users?

We Needs to Sign Up For Various Applications and
Sites Separately.

Why?
We have already sign up on many, using different
usernames, that going back to one of them and
trying to remember our credentials is sometimes
impossible.
Now a days, most of the sites offering alternative
way to sign up,

By allowing us to use other sites accounts.
Like
• Google Account
• Twitter
• GitHub
• Facebook

It feels like a long and arduous task.

But fear not, Omniauth is here to help.
Omniauth allows us to easily
integrate more than sixty
 authentication providers!
Preparing Application

Create Rails application
rails new application_name

In GEMFILE add
gem 'omniauth'

Then,
Bundle install
Creating a Provider
How add a provider to Omniauth?

We need to sign up as a developer on
providers site.

Then just we will have to make two settings in
our application regarding
Username and Password.
If you want to use Facebook authentication
head over to
                                             Create new
developers.facebook.com/apps                  app here
and
click on “Create New App”
Getting our App id/ API key and App Secret from settings
Add Provider To The App
      Create a new file under config/initializers called
      omniauth.rb.

Rails.application.config.middleware.use OmniAuth::Builder do

provider :facebook, YOUR_APP_ID, YOUR_APP_SECRET

end


       Create the Controller Session

              $> rails generate controller sessions new create failure
Set path in routes.rb
get '/login', :to => 'sessions#new', :as => :login

match '/auth/:provider/callback', :to => 'sessions#create'

match '/auth/failure', :to => 'sessions#failure'




In Controller app/controllers/sessions_controller.rb just add
def Create

auth_hash = request.env['omniauth.auth']

render :text => auth_hash.inspect

end
Now make sure everything is working.

Point the browser to

localhost:3000/auth/facebook/
Then,

we’ll be redirected to Facebook so we can authorize our app.

We will Authorize it, and we will be redirected back to our app

and see a hash with some information.

In between will be our name, our Facebook user id, and our email, among other things.

If error occurred then,
Change Some Setting in Facebook/apps for site
redirection


                                                      Blank App
                                                      Domains




                                        Change site
                                           URL
Thanks

More Related Content

What's hot

App builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackalApp builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackal
Nihal Ismail
 
Salesforce Marketing Cloud connector for Wordpress WooCommerce
Salesforce Marketing Cloud connector for Wordpress WooCommerceSalesforce Marketing Cloud connector for Wordpress WooCommerce
Salesforce Marketing Cloud connector for Wordpress WooCommerce
Webkul Software Pvt. Ltd.
 
How to integrate a subscription form with WordPress using a free plugin?
How to integrate a subscription form with WordPress using a free plugin?How to integrate a subscription form with WordPress using a free plugin?
How to integrate a subscription form with WordPress using a free plugin?
GeniusContacts
 
How to Build Your Own Social Network with Elgg?
How to Build Your Own Social Network with Elgg?How to Build Your Own Social Network with Elgg?
How to Build Your Own Social Network with Elgg?
Jaakko Naakka
 
Directory submission
Directory submissionDirectory submission
Directory submission
Srinivas Sarakadam, SEO expert
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
Puneet Duggal
 
Urello wcabq
Urello wcabqUrello wcabq
Urello wcabq
Elizabeth Urello
 
Mobile Website Tutorial
Mobile Website TutorialMobile Website Tutorial
Mobile Website Tutorial
PuttiApps
 
Designing REST API
Designing REST APIDesigning REST API
Designing REST API
Joseph Jude
 
Mule roles
Mule rolesMule roles
Mule roles
Son Nguyen
 
Forms authentication in asp dot net
Forms authentication in asp dot netForms authentication in asp dot net
Forms authentication in asp dot net
Pooja Gaikwad
 
Creating an app on Ribily Part 3 flow creation
Creating an app on Ribily Part 3 flow creationCreating an app on Ribily Part 3 flow creation
Creating an app on Ribily Part 3 flow creation
Sagar Kalkhair
 
Beyond the Theme - Using WordPress as an API
Beyond the Theme - Using WordPress as an APIBeyond the Theme - Using WordPress as an API
Beyond the Theme - Using WordPress as an API
David Tufts
 
DevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-WarblerDevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-Warbler
Mark Dunlap
 
Descriptomatic review
Descriptomatic reviewDescriptomatic review
Descriptomatic review
Fred Kong
 
O365con14 - a developer jam with yammer
O365con14 - a developer jam with yammerO365con14 - a developer jam with yammer
O365con14 - a developer jam with yammer
NCCOMMS
 
Joomla Amazon Affiliate
Joomla Amazon AffiliateJoomla Amazon Affiliate
Joomla Amazon Affiliate
Webkul Software Pvt. Ltd.
 
Let's do SPA
Let's do SPALet's do SPA
Let's do SPA
Marek Piasecki
 
JoomlaEXPO: Search Engine Friendly URLs - Azrul.com
JoomlaEXPO: Search Engine Friendly URLs - Azrul.comJoomlaEXPO: Search Engine Friendly URLs - Azrul.com
JoomlaEXPO: Search Engine Friendly URLs - Azrul.com
John Coonen
 

What's hot (19)

App builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackalApp builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackal
 
Salesforce Marketing Cloud connector for Wordpress WooCommerce
Salesforce Marketing Cloud connector for Wordpress WooCommerceSalesforce Marketing Cloud connector for Wordpress WooCommerce
Salesforce Marketing Cloud connector for Wordpress WooCommerce
 
How to integrate a subscription form with WordPress using a free plugin?
How to integrate a subscription form with WordPress using a free plugin?How to integrate a subscription form with WordPress using a free plugin?
How to integrate a subscription form with WordPress using a free plugin?
 
How to Build Your Own Social Network with Elgg?
How to Build Your Own Social Network with Elgg?How to Build Your Own Social Network with Elgg?
How to Build Your Own Social Network with Elgg?
 
Directory submission
Directory submissionDirectory submission
Directory submission
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
 
Urello wcabq
Urello wcabqUrello wcabq
Urello wcabq
 
Mobile Website Tutorial
Mobile Website TutorialMobile Website Tutorial
Mobile Website Tutorial
 
Designing REST API
Designing REST APIDesigning REST API
Designing REST API
 
Mule roles
Mule rolesMule roles
Mule roles
 
Forms authentication in asp dot net
Forms authentication in asp dot netForms authentication in asp dot net
Forms authentication in asp dot net
 
Creating an app on Ribily Part 3 flow creation
Creating an app on Ribily Part 3 flow creationCreating an app on Ribily Part 3 flow creation
Creating an app on Ribily Part 3 flow creation
 
Beyond the Theme - Using WordPress as an API
Beyond the Theme - Using WordPress as an APIBeyond the Theme - Using WordPress as an API
Beyond the Theme - Using WordPress as an API
 
DevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-WarblerDevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-Warbler
 
Descriptomatic review
Descriptomatic reviewDescriptomatic review
Descriptomatic review
 
O365con14 - a developer jam with yammer
O365con14 - a developer jam with yammerO365con14 - a developer jam with yammer
O365con14 - a developer jam with yammer
 
Joomla Amazon Affiliate
Joomla Amazon AffiliateJoomla Amazon Affiliate
Joomla Amazon Affiliate
 
Let's do SPA
Let's do SPALet's do SPA
Let's do SPA
 
JoomlaEXPO: Search Engine Friendly URLs - Azrul.com
JoomlaEXPO: Search Engine Friendly URLs - Azrul.comJoomlaEXPO: Search Engine Friendly URLs - Azrul.com
JoomlaEXPO: Search Engine Friendly URLs - Azrul.com
 

Similar to Omniauth

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
h_marvin
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook app
OS-Cubed, Inc.
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1
Nabeel Yoosuf
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0  - Part 1Introduction to OAuth 2.0  - Part 1
Introduction to OAuth 2.0 - Part 1
Nabeel Yoosuf
 
Facebook SSO.docx
Facebook SSO.docxFacebook SSO.docx
Facebook SSO.docx
ehathis
 
How to create Zoom Meet with Pega
How to create Zoom Meet with PegaHow to create Zoom Meet with Pega
How to create Zoom Meet with Pega
SamuelJude1
 
Facebook Coin
Facebook CoinFacebook Coin
Facebook Coin
Sathiyamoorthi
 
Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...
Katy Slemon
 
Integrate facebook using mule esb
Integrate facebook using mule esbIntegrate facebook using mule esb
Integrate facebook using mule esb
Sanjeet Pandey
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
Mihir Shah
 
Intro To Bebo Applications by Thought Labs
Intro To Bebo Applications by Thought LabsIntro To Bebo Applications by Thought Labs
Intro To Bebo Applications by Thought Labs
John Maver
 
Dreamwares_Salesforce Updated
Dreamwares_Salesforce UpdatedDreamwares_Salesforce Updated
Dreamwares_Salesforce Updated
Amit Ahuja
 
Progressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting StartedProgressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting Started
Gaurav Behere
 
Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
ColdFusionConference
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudSharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
Danny Jessee
 
Facebook + Ruby
Facebook + RubyFacebook + Ruby
Facebook + Ruby
Alex Koppel
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010,Claims-Based Identity, Facebook, and the CloudSharePoint 2010,Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
Danny Jessee
 
Login Register with Social Account using PHP
Login Register with Social Account using PHPLogin Register with Social Account using PHP
Login Register with Social Account using PHP
AtozWebhelp
 
Dreamwares_SF Expertise
Dreamwares_SF ExpertiseDreamwares_SF Expertise
Dreamwares_SF Expertise
Manidipa Mitra
 
Mule with facebook
Mule with facebookMule with facebook
Mule with facebook
D.Rajesh Kumar
 

Similar to Omniauth (20)

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook app
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0  - Part 1Introduction to OAuth 2.0  - Part 1
Introduction to OAuth 2.0 - Part 1
 
Facebook SSO.docx
Facebook SSO.docxFacebook SSO.docx
Facebook SSO.docx
 
How to create Zoom Meet with Pega
How to create Zoom Meet with PegaHow to create Zoom Meet with Pega
How to create Zoom Meet with Pega
 
Facebook Coin
Facebook CoinFacebook Coin
Facebook Coin
 
Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...
 
Integrate facebook using mule esb
Integrate facebook using mule esbIntegrate facebook using mule esb
Integrate facebook using mule esb
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
Intro To Bebo Applications by Thought Labs
Intro To Bebo Applications by Thought LabsIntro To Bebo Applications by Thought Labs
Intro To Bebo Applications by Thought Labs
 
Dreamwares_Salesforce Updated
Dreamwares_Salesforce UpdatedDreamwares_Salesforce Updated
Dreamwares_Salesforce Updated
 
Progressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting StartedProgressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting Started
 
Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudSharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
 
Facebook + Ruby
Facebook + RubyFacebook + Ruby
Facebook + Ruby
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010,Claims-Based Identity, Facebook, and the CloudSharePoint 2010,Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
 
Login Register with Social Account using PHP
Login Register with Social Account using PHPLogin Register with Social Account using PHP
Login Register with Social Account using PHP
 
Dreamwares_SF Expertise
Dreamwares_SF ExpertiseDreamwares_SF Expertise
Dreamwares_SF Expertise
 
Mule with facebook
Mule with facebookMule with facebook
Mule with facebook
 

Recently uploaded

AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 

Recently uploaded (20)

AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 

Omniauth

  • 1. Omniauth Gem All, Every and Authentication Everywhere Omni + auth By Sumit Munot
  • 2. How to Use Omniauth to Authenticate Our Users? We Needs to Sign Up For Various Applications and Sites Separately. Why? We have already sign up on many, using different usernames, that going back to one of them and trying to remember our credentials is sometimes impossible.
  • 3. Now a days, most of the sites offering alternative way to sign up, By allowing us to use other sites accounts. Like • Google Account • Twitter • GitHub • Facebook It feels like a long and arduous task. But fear not, Omniauth is here to help.
  • 4. Omniauth allows us to easily integrate more than sixty authentication providers!
  • 5. Preparing Application Create Rails application rails new application_name In GEMFILE add gem 'omniauth' Then, Bundle install
  • 6. Creating a Provider How add a provider to Omniauth? We need to sign up as a developer on providers site. Then just we will have to make two settings in our application regarding Username and Password.
  • 7. If you want to use Facebook authentication head over to Create new developers.facebook.com/apps app here and click on “Create New App”
  • 8. Getting our App id/ API key and App Secret from settings
  • 9. Add Provider To The App Create a new file under config/initializers called omniauth.rb. Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, YOUR_APP_ID, YOUR_APP_SECRET end Create the Controller Session $> rails generate controller sessions new create failure
  • 10. Set path in routes.rb get '/login', :to => 'sessions#new', :as => :login match '/auth/:provider/callback', :to => 'sessions#create' match '/auth/failure', :to => 'sessions#failure' In Controller app/controllers/sessions_controller.rb just add def Create auth_hash = request.env['omniauth.auth'] render :text => auth_hash.inspect end
  • 11. Now make sure everything is working. Point the browser to localhost:3000/auth/facebook/ Then, we’ll be redirected to Facebook so we can authorize our app. We will Authorize it, and we will be redirected back to our app and see a hash with some information. In between will be our name, our Facebook user id, and our email, among other things. If error occurred then,
  • 12. Change Some Setting in Facebook/apps for site redirection Blank App Domains Change site URL